package com.gpframework.module.process.domain.req;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gpframework.common.utils.DateUtils;
import com.gpframework.common.utils.StringUtils;
import com.gpframework.module.base.domain.req.BaseReq;
import com.gpframework.module.process.domain.GpRevisionTable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @ClassName GpRevisionTableReq
 * @Author gpframework
 * @Date 2023-12-20
 * @Version 1.0.0
 * @Description 列表查询信息体
 */
@Data
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@Accessors(chain = true)
public class GpRevisionTableReq extends BaseReq {
    private static final long serialVersionUID = 1L;

         @ApiModelProperty("${column.columnComment}")
     private Long id;
     @ApiModelProperty("品牌id")
     private String brandId;
     @ApiModelProperty("品牌名称")
     private String brandName;
     @ApiModelProperty("来料检验单id")
     private Long incomingInspectId;
     @ApiModelProperty("订单号")
     private String sn;
     @ApiModelProperty("批次")
     private String batchNo;
     @ApiModelProperty("原来品名")
     private String productName;
     @ApiModelProperty("原来颜色")
     private String productColor;
     @ApiModelProperty("到货单id")
     private Long incomingId;
     @ApiModelProperty("回货数量")
     private Long returnNum;
     @ApiModelProperty("改后品名")
     private String changedProductName;
     @ApiModelProperty("改后颜色")
     private String changedProductColor;
     @ApiModelProperty("改后数量")
     private Long changedNum;
     @ApiModelProperty("项目")
     private String project;
     @ApiModelProperty("改标")
     private String changedLabel;
     @ApiModelProperty("改后坑位")
     private String changedHole;
     @ApiModelProperty("更改日期")
     private Date changeDate;
     @ApiModelProperty("改标签名")
     private String changedSignature;
     @ApiModelProperty("抽查签名1")
     private String randSignature1;
     @ApiModelProperty("抽查签名2")
     private String randSignature2;
     @ApiModelProperty("审核人id")
     private Long auditId;
     @ApiModelProperty("审核人")
     private String auditMan;
     @ApiModelProperty("审核时间")
     private Date auditTime;
     @ApiModelProperty("审核状态")
     private String auditStatus;
     @ApiModelProperty("操作人id")
     private Long operatorId;
     @ApiModelProperty("操作人")
     private String operatorName;
    /** 操作人编号 */
    private String operatorNum;
     @ApiModelProperty("操作时间")
     private Date operatorTime;
     @ApiModelProperty("排序")
     private Integer sort;
     @ApiModelProperty("备注")
     private String remarks;
     @ApiModelProperty("创建者")
     private String createBy;
     @ApiModelProperty("创建时间")
     private Date createTime;
     @ApiModelProperty("更新者")
     private String updateBy;
     @ApiModelProperty("更新时间")
     private Date updateTime;
     @ApiModelProperty("删除标记;0未删除。1已删除。")
     private Integer delStatus;
    /**审批人名称 */
    @ApiModelProperty("审批人名称")
    private String examinName;

    @ApiModelProperty("查询条件（订单号/客户名）")
    private String searchName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date searchDate;
    /**
    * @Description 生成查询wrapper
    * @Author greatplan@qq.com
    * @Date 2020-11-04 16:04
    * @Param [lqw]
    * @Param [isVO] 是否vo查询体，true的话走的是mapper.xml里面的查询语句，不过查询语法还是mybatis-plus，主要用于某些关联查询出一些非数据表字段
    * @Return void
    */
    public void generatorQuery(QueryWrapper<GpRevisionTable> lqw,boolean isVo) {
        String alias = "";
        if (isVo) {
            alias = "gp.";
            lqw.eq(alias+"del_status",0);
            lqw.orderByDesc(alias+"create_time");
        }
        if (this.getId() != null){
        lqw.eq(alias+"id" ,this.getId());
        }
        if (StringUtils.isNotBlank(this.getBrandId())){
        lqw.eq(alias+"brand_id" ,this.getBrandId());
        }
        if (StringUtils.isNotBlank(this.getBrandName())){
            lqw.like(alias+"brand_name",this.getBrandName());
        }
        if (this.getIncomingInspectId() != null){
        lqw.eq(alias+"incoming_inspect_id" ,this.getIncomingInspectId());
        }
        if (StringUtils.isNotBlank(this.getSn())){
        lqw.like(alias+"sn" ,this.getSn());
        }
        if (StringUtils.isNotBlank(this.getBatchNo())){
        lqw.like(alias+"batch_no" ,this.getBatchNo());
        }
        if (StringUtils.isNotBlank(this.getProductName())){
            lqw.like(alias+"product_name",this.getProductName());
        }
        if (StringUtils.isNotBlank(this.getProductColor())){
        lqw.like(alias+"product_color" ,this.getProductColor());
        }
        if (this.getIncomingId()!=null){
        lqw.eq(alias+"incoming_id" ,this.getIncomingId());
        }
        if (this.getReturnNum() != null){
        lqw.eq(alias+"return_num" ,this.getReturnNum());
        }
        if (StringUtils.isNotBlank(this.getChangedProductName())){
            lqw.like(alias+"changed_product_name",this.getChangedProductName());
        }
        if (this.getChangedProductColor() != null){
        lqw.eq(alias+"changed_product_color" ,this.getChangedProductColor());
        }
        if (this.getChangedNum() != null){
        lqw.eq(alias+"changed_num" ,this.getChangedNum());
        }
        if (StringUtils.isNotBlank(this.getProject())){
        lqw.eq(alias+"project" ,this.getProject());
        }
        if (StringUtils.isNotBlank(this.getChangedLabel())){
        lqw.eq(alias+"changed_label" ,this.getChangedLabel());
        }
        if (StringUtils.isNotBlank(this.getChangedHole())){
        lqw.eq(alias+"changed_hole" ,this.getChangedHole());
        }
        if (this.getChangeDate() != null){
        lqw.eq(alias+"change_date" ,this.getChangeDate());
        }
        if (StringUtils.isNotBlank(this.getChangedSignature())){
        lqw.eq(alias+"changed_signature" ,this.getChangedSignature());
        }
        if (StringUtils.isNotBlank(this.getRandSignature1())){
        lqw.eq(alias+"rand_signature1" ,this.getRandSignature1());
        }
        if (StringUtils.isNotBlank(this.getRandSignature2())){
        lqw.eq(alias+"rand_signature2" ,this.getRandSignature2());
        }
        if (this.getAuditId() != null){
        lqw.eq(alias+"audit_id" ,this.getAuditId());
        }
        if (StringUtils.isNotBlank(this.getAuditMan())){
        lqw.eq(alias+"audit_man" ,this.getAuditMan());
        }
        if (this.getAuditTime()!=null){
        lqw.eq(alias+"audit_time" ,this.getAuditTime());
        }
        if (StringUtils.isNotBlank(this.getAuditStatus())){
        lqw.eq(alias+"audit_status" ,this.getAuditStatus());
        }
        if (this.getOperatorId() != null){
        lqw.eq(alias+"operator_id" ,this.getOperatorId());
        }
        if (StringUtils.isNotBlank(this.getOperatorName())){
        lqw.eq(alias+"operator_name" ,this.getOperatorName());
        }
        if (this.getOperatorTime() != null){
        lqw.eq(alias+"operator_time" ,this.getOperatorTime());
        }
        if (this.getSort() != null){
        lqw.eq(alias+"sort" ,this.getSort());
        }
        if (StringUtils.isNotBlank(this.getRemarks())){
        lqw.eq(alias+"remarks" ,this.getRemarks());
        }
        if (StringUtils.isNotBlank(this.getCreateBy())){
        lqw.eq(alias+"create_by" ,this.getCreateBy());
        }
        if (this.getCreateTime() != null){
        lqw.eq(alias+"create_time" ,this.getCreateTime());
        }
        if (StringUtils.isNotBlank(this.getUpdateBy())){
        lqw.eq(alias+"update_by" ,this.getUpdateBy());
        }
        if (this.getUpdateTime() != null){
        lqw.eq(alias+"update_time" ,this.getUpdateTime());
        }
        if (this.getDelStatus() != null){
        lqw.eq(alias+"del_status" ,this.getDelStatus());
        }
        if (StringUtils.isNotBlank(this.getSearchName())) {
            lqw.and(wrapper -> wrapper.like("gp.sn", this.getSearchName()).or().like("gp.product_name", this.getSearchName()).or().like("gp.product_color", this.getSearchName()));
        }
        if (this.getSearchDate() != null) {
            lqw.apply("DATE_FORMAT(gp.create_time, '%Y-%m-%d') = '" + DateUtils.dateTime(this.getSearchDate()) + "'");
        }
    }
}
